#ifndef __TRAINMETHOD_H__
#define __TRAINMETHOD_H__


#include <iostream>

#include  "svm.h"
#include <armadillo>

class BTMethod
{
private:
    /* data */
public:
    BTMethod();
    ~BTMethod();

public:
    virtual int create_model(arma::mat data, arma::mat label) = 0;
    virtual int data_predict(arma::mat data) = 0;
};


class LDA : public BTMethod
{
private:
    /* data */
public:
    LDA(/* args */);
    ~LDA();
    int create_model(arma::mat data, arma::mat label); 
    // int create_model(void* argv=nullptr, void* argv2=nullptr); 

    int data_predict(arma::mat data);

};



namespace SVM_Stru
{
    struct TrainParaStru
    {
        arma::mat data;
        arma::mat label;
    };
}

class SVM : public BTMethod
{
private:
    /* data */

public:
    SVM(std::string model_path);
    ~SVM();
    int create_model(arma::mat data, arma::mat label); 
    int data_predict(arma::mat data);
    int data_predict_test(const arma::mat &data, const arma::mat &label);

    int Cg_optimization_gridSearch(const svm_problem *prob, svm_parameter *param);
    double do_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold=5);



private:
    std::string modelPath;
    struct svm_parameter param;		// set by parse_command_line
    struct svm_problem prob;		// set by read_problem
    struct svm_model *model;
    // struct svm_node *x_space;
    int cross_validation;
    // int nr_fold;

    bool predict_probability;

    // static char *line = NULL;
    // static int max_line_len;
private:
    void set_parameter();


};
#endif
